package com.jason.thread.sync;

/**
 * @description:
 * @author: jason.jia
 * @create: 2019-01-29 15:10
 **/
public class TestSync implements Runnable {

    private int balance;

    @Override
    public void run() {
        for (int i = 0; i < 50; i++) {
            increment();
            System.out.println("balance is " + balance);
        }
    }

    private  void increment() {
        int i = balance;
        try {
            Thread.currentThread().sleep(0);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        balance = i + 1;
    }
}
